//
// Created by 成飞 on 2024/1/6.
//

#ifndef ORDERKV_BUFFER_H
#define ORDERKV_BUFFER_H

#include <map>
#include <string>
#include <cstdio>
#include <atomic>
#include <fstream>
#include <vector>
#include <set>
#include "db/meta_data.h"

namespace vstore{
    using std::vector;
    using std::string;
    using std::pair;
    using std::string_view;

    class WBuffer {
    public:
        size_t size{}; // only record the value size, ignore the key size
        meta::fid fileNo{};
        std::string fileNo8Digits;
        std::atomic_uint8_t status{}; // record whether the buffer has written to disk, 0 means it's ready, 1 means this buffer is being written to SSD
        FILE *logger;
        std::string loggerFilePathStr;


    public:
        virtual bool put(std::string& key, std::string& val) = 0;

        virtual bool put_without_log(std::string& key, std::string& val) = 0;

        virtual void query(const std::string& key, std::string& val)  = 0;

        virtual void range_query(const string& startKey, const string& endKey, int len, vector<pair<string_view, string_view>>& ret) = 0;
//
//        virtual bool remove(const char *key) = 0;

 //sync?
        virtual void dump() = 0;

        virtual void ready() = 0;
    };

}

#endif //ORDERKV_BUFFER_H
